import {
  behavior as computedBehavior
} from "miniprogram-computed";
import {
  isCellEmpty
} from "../../../../utils/util"

Component({
  behaviors: [computedBehavior],
  /**
   * 组件的属性列表
   */
  properties: {
    userInfo: {
      type: Object,
      value: {}
    },
    powers: {
      type: String,
      value: ""
    },
    noticeNums: {
      type: Number,
      value: 0
    }
  },
  computed: {
    isLogin(data) {
      const {
        userInfo
      } = data;

      let result = false;
      if (userInfo && !isCellEmpty(userInfo.id)) {
        result = true
      }

      return result;
    },
    hasGuide(data) {
      const {
        powers
      } = data;

      return powers.indexOf("12-206") >= 0;
    },
  },

  /**
   * 组件的初始数据
   */
  data: {

  },

  /**
   * 组件的方法列表
   */
  methods: {
    handleGotoUser() {
      this.triggerEvent("onUser");
    },
    handleClickExpire() {
      this.triggerEvent("onExpire");
    },
    handleClickVip() {
      this.triggerEvent("onVip");
    },
    handleClickGuide() {
      this.triggerEvent("onGuide");
    },
    handleClickMyCode() {
      this.triggerEvent("onMyCode");
    },
    handleClickMessage() {
      this.triggerEvent("onMessage");
    }
  }
})